package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.GoodsMapper;
import com.itheima.pojo.Goods;
import com.itheima.service.GoodsService;
import org.springframework.stereotype.Service;

@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
    @Override
    public boolean deduckStore(Long goodId, Integer num) {
        Goods goods = this.baseMapper.selectById(goodId);
        if(goods.getStokeNum() > num){
            goods.setStokeNum(goods.getStokeNum() - num);
            this.updateById(goods);
        }
        return true;
    }
}
